package com.jic.manager.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.manager.mapper.CmsRefPagetypesMapper;
import com.jic.manager.entity.CmsRefPagetypes;
import com.jic.manager.service.CmsRefPagetypesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 对象关联的页面类型
 * @author : 
 * @email : 
 * @since : 2020-03-05 12:01:06
 * @version : v1.0.0
 */
@Service
public class CmsRefPagetypesServiceImpl implements CmsRefPagetypesService{

    @Autowired
    private CmsRefPagetypesMapper cmsRefPagetypesMapper;

    @Override
    public long insert(CmsRefPagetypes cmsRefPagetypes) {
        long flag = cmsRefPagetypesMapper.insert(cmsRefPagetypes);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return cmsRefPagetypesMapper.delete(id);
    }

    @Override
    public long update(CmsRefPagetypes cmsRefPagetypes) {
        return cmsRefPagetypesMapper.update(cmsRefPagetypes);
    }

    @Override
    public CmsRefPagetypes queryByPrimaryKey(Long id){
        return cmsRefPagetypesMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<CmsRefPagetypes> query(CmsRefPagetypes cmsRefPagetypes){
        return cmsRefPagetypesMapper.query(cmsRefPagetypes);
    }

    @Override
    public PageResult<CmsRefPagetypes> queryPage(CmsRefPagetypes cmsRefPagetypes, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<CmsRefPagetypes> list = cmsRefPagetypesMapper.queryPage(startIndex, pageQuery.getLimit(), cmsRefPagetypes);
        long count = cmsRefPagetypesMapper.queryPageCount(cmsRefPagetypes);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}